package com.itheima.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

//@Controller
//@RequestMapping("/user/")
@RestController
public class UserController {

    //rest风格访问路径完整书写方式
  /*  @RequestMapping("/{id}")
    //使用@PathVariable注解获取路径上配置的具名变量，该配置可以使用多次
    public String restLocation(@PathVariable Integer id){
        System.out.println("restful is running ...."+id);
        return "success.jsp";
    }*/

    /*@RequestMapping(value="{id}",method= RequestMethod.GET)
    @GetMapping("{id}")
    //使用@PathVariable注解获取路径上配置的具名变量，该配置可以使用多次
    public String get(@PathVariable Integer id){
        System.out.println("restful is running ...."+id);
        return "success.jsp";
    }*/

    /*@RequestMapping(value="{id}",method= RequestMethod.POST)
    @PostMapping("{id}")
    //使用@PathVariable注解获取路径上配置的具名变量，该配置可以使用多次
    public String post(@PathVariable Integer id){
        System.out.println("restful is running ...."+id);
        return "success.jsp";
    }*/
   /* @RequestMapping(value="{id}",method= RequestMethod.PUT)
    @PutMapping("{id}")
    //使用@PathVariable注解获取路径上配置的具名变量，该配置可以使用多次
    public String put(@PathVariable Integer id){
        System.out.println("restful is running ...."+id);
        return "success.jsp";
    }*/

   /* @RequestMapping(value="{id}",method= RequestMethod.DELETE)
    @DeleteMapping("{id}")
    //使用@PathVariable注解获取路径上配置的具名变量，该配置可以使用多次
    public String delete(@PathVariable Integer id){
        System.out.println("restful is running ...."+id);
        return "success.jsp";
    }*/

    @RequestMapping(value="/user/{id}",method= RequestMethod.DELETE) //此方式返回的是字符串，无法跳转至指定页面
    //@DeleteMapping("{id}") //此方式返回值可以跳转至指定页面
    //使用@PathVariable注解获取路径上配置的具名变量，该配置可以使用多次
    //@ResponseBody
    public String delete(@PathVariable String id){
        System.out.println("restful is running ...."+id);
        return "success.jsp";
    }

}
